package com.mapaower.payment.repository;

import com.mapaower.payment.entity.MembershipRecharge;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface MembershipRechargeRepository extends JpaRepository<MembershipRecharge, Long> {
    
    /**
     * 根据用户ID查询充值记录
     */
    List<MembershipRecharge> findByUserIdOrderByCreateTimeDesc(Long userId);
    
    /**
     * 根据用户ID和状态查询充值记录
     */
    List<MembershipRecharge> findByUserIdAndStatusOrderByCreateTimeDesc(Long userId, MembershipRecharge.RechargeStatus status);
    
    /**
     * 根据交易流水号查询充值记录
     */
    Optional<MembershipRecharge> findByTransactionId(String transactionId);
}